package com.kaiwukj.android.ufamily.mvp.ui.page.keeper;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.app.base.review.BaseActivity;
import com.kaiwukj.android.ufamily.app.constant.ARouterUrlKt;
import com.kaiwukj.android.ufamily.mvp.http.entity.event.KeeperEvent;

import org.greenrobot.eventbus.Subscribe;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = ARouterUrlKt.MineKeeperContainerUrl)
public class KeeperContainerActivity extends BaseActivity {
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.container_right)
    ViewGroup containerRight;
    @BindView(R.id.tv_right)
    TextView tvRight;

    @OnClick(R.id.container_left)
    void onBackClick() {
        onBackPressedSupport();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_base_content;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        tvTitle.setVisibility(View.GONE);
        loadRootFragment(R.id.fl_content, KeeperBindFragment.newInstance(0));
        containerRight.setVisibility(View.VISIBLE);
        tvRight.setBackgroundResource(R.mipmap.ic_mine_service_cservice);
        tvRight.setOnClickListener(v -> ARouter.getInstance().build(ARouterUrlKt.KeeperPickUrl)
                .withInt("flag", 1)
                .navigation());
    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

    @Subscribe
    public void onKeeperEvent(KeeperEvent event) {
        if (event.getCode() == KeeperEvent.BIND) {
            finish();
        }
    }
}
